<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :SwiperItem="SwiperItem" :SwiperList="SwiperList"></home-swiper>
    <Recommend></Recommend>
    <weekend></weekend>
  </div>
</template>
<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import Recommend from './components/Recommend'
import Weekend from './components/Weekend'
export default {
  components: {
    HomeHeader,
    HomeSwiper,
    Recommend,
    Weekend
  },
  data() {
    return {
      city: '',
      SwiperItem: '',
      SwiperList: ''
    }
  },
  methods: {
    async getHomeInfo() {
      //获取hearder组件的数据
      const result = await this.$http.get('/api/index.json')
      this.getHomeInfoSuccc(result.data)
      //获取Swiper组件的数组
      this.getSwiperData(result.data)
    },
    getSwiperData(res) {
      if (res.ret && res.data) {
        const data = res.data
        this.SwiperItem = res.data.swiperList
        this.SwiperList = res.data.iconList
        console.log(res.data.iconList)
      }
    },
    getHomeInfoSuccc(res) {
      if (res.ret && res.data) {
        const data = res.data
        this.city = data.city
      }
    }
  },
  mounted() {
    this.getHomeInfo()
  }
}
</script>
<style lang="stylus" scoped></style>